home *** CD-ROM | disk | FTP | other *** search
- Path: ukcc.uky.edu!JJSTEP00
- From: JJSTEP00@ukcc.uky.edu (Jason Stephenson)
- Newsgroups: comp.lang.c
- Subject: pseudo-random numbers
- Date: Tue, 09 Jan 96 15:05:04 EST
- Organization: The University of Kentucky
- Message-ID: <17709D420S86.JJSTEP00@ukcc.uky.edu>
- NNTP-Posting-Host: ukcc.uky.edu
-
- I know what the c.l.c. FAQ says about pseudo-random numbers, so I wonder why
- I seem to get "better" results with "rand() % n + 1" than I get when I use
- "n * rand() / RAND_MAX + 1" Am I missing some parenthesis or something?
- Oh yeah, and I usually call "srand(clock())" once in the initialization of
- my program. With the first, I get an integer between 1 and n. With the
- second, I almost always get a value of 1 or 2.
-
- +----------------------------+-----------------------------+
- | Jason Stephenson | "Curiouser and curiouser," |
- | jjstep00@ukcc.uky.edu | said Alice. |
- +----------------------------+-----------------------------+
-